
//坐标

function pos(n) {
  var m;
  if (n <= 50) {
    return m = 0;
  }
  if (n >= 50 && n <= 100) {
    return m = 1;
  }
  if (n >= 100 && n <= 150) {
    return m = 2;
  }
  if (n >= 150 && n <= 200) {
    return m = 3;
  }
  if (n >= 200 && n <= 250) {
    return m = 4;
  }
  if (n >= 250 && n <= 300) {
    return m = 5;
  }
}
//点击操作
var r = 3, l = 2;
function tdp() {
  var tdi = "b";
  document.getElementById(tdi + r + l).style.backgroundColor = "";
  if (event.touches.length == 1) {
    var xT = event.touches[0].pageX;
    var yT = event.touches[0].pageY;
  }else{
      return;
  }
  if (xT > 300 || yT > 300) {
    alert("这是外面!");
    document.getElementById(tdi + r + l).style.backgroundColor = "#EEA2AD";
    return;
  }
  l = pos(xT);
  r = pos(yT);
  document.getElementById(tdi + r + l).style.backgroundColor = "#5CACEE";
  if (r == 0 || r == 2 || r == 4) {
    document.getElementById(tdi + r + l).style.backgroundColor = "#EE9A49";
  }
  document.getElementById("bid").innerHTML = "点击的坐标：" + xT + ";" + yT;
}
function phtouch() {
  /*
   var x = document.getElementById("b01").offsetLeft
   var y = document.getElementById("b01").offsetTop
   var wi = document.getElementById('b01').offsetWidth
   var he = document.getElementById('b01').offsetHeight
   */
  
  tdp();
}
//手移开操作
function phedtouch() {

  //document.getElementById("bid").innerHTML = "";

}

document.addEventListener("touchstart", phtouch, false);
document.addEventListener("touchend", phedtouch, false);

//画表格
function tab() {
  var tdi = "b";
  var tx ="";
		for (var x = 0; x < 6; x++) {
    tx += "<tr>";
    for (var y = 0; y < 6; y++) {
      tx += "<td id=b" + x + y + "></td>";
    }
    tx += "</tr>";
		}
  document.getElementById("ta").innerHTML = tx;
  document.getElementById(tdi+r+l).style.backgroundColor = "#EEA2AD";
  //lmv();
  //keyp();
 // pau();
}
window.onload = tab;
